Approximately 1 in 3 people on antiretroviral therapy (ART) in sub-Saharan Africa experience virologic failure within two years of antiretroviral therapy treatment initiation. The 2013 World Health Organization (WHO) HIV treatment guidelines recommend management of virologic failure by switching patients to second line therapy after two consecutive detectable HIV RNA viral load (viral load) measurements >1,000 copies/mL. As viral load testing is scaled up in sub-Saharan Africa, these recommendations are likely to have important ramifications on the sustainability of treatment programs. The absence of concomitant resistance testing at the time of failure has the potential to threaten the sustainability of HIV treatment programs by 1) promoting unnecessary switching of patients with wild-type virus to costly second-line therapy and 2) continuing patients with low viral load on first-line therapy despite the presence of unidentified drug resistance. To date, cost-effectiveness studies of resistance testing in sub-Saharan Africa have generated contrasting results, partially due to lack of primary data on the efficacy of resistance testing. As PEPFAR embarks on its third phase of implementation with a focus on sustainability, it is critical to develop a data-driven approach to management of virologic failure in sub-Saharan Africa, and maximize the proportion of patients who sustain successful completion of the HIV continuum of care. Our over-arching goal is to determine whether routine resistance testing at virologic failure in sub-Saharan Africa improves rates of sustained virologic suppression, and if so, at what relative cost to treatment programs. We propose to enroll patients from HIV clinics in two PEPFAR-focus countries in sub-Saharan Africa into a randomized controlled trial to complete the following aims: Aim 1: Estimate the effectiveness of resistance testing-based management of virologic failure (resistance testing arm), versus viral-load based management per WHO guidelines (standard of care arm). We hypothesize that resistance testing-based management will be superior to standard of care management measured by the proportion of patients with undetectable viral load 9 months after detection of virologic failure. Aim 2: Evaluate the cost effectiveness of resistance-testing versus viral load-based management of virologic failure in sub-Saharan Africa. We hypothesize that resistance testing will be cost effective, because the cost of the assay will be offset by downstream cost savings through reduced use of second line therapy. Results of this study will help optimize clinical management and allocation of resources for ministries of health and multinational HIV program partners in the region.